package test.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import test.mapper.UserMapper;
import test.module.User;
import test.service.UserService;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : example
 * @ Author: XuLeHuang
 * @ Date: 2022/10/5 18:29
 * @ Description:
 */
@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    @DS("master")
    public List selectAllWithMaster() {
        return userMapper.selectAllWithMaster();

    }

    @Override
    @DS("slave_1")
    public List selectAllWithSlave() {
        return jdbcTemplate.queryForList("select * from t_user");
    }
}
